package com.example.yiwei.crm.view.frament.clueDetailedMenu;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.yiwei.crm.R;
import com.example.yiwei.crm.data.GetClue;
import com.example.yiwei.crm.entity.ClueMeesageEntity;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

/**
 * Created by Administrator on 2017/1/12.
 */

public class clueOtherFragment extends Fragment{
    TextView txt_creater,txt_create_time,txt_updater,txt_update_time,txt_respectful,txt_clue_source,txt_department,
    txt_next_time,txt_next_content,txt_addtional;
    ClueMeesageEntity clue;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootview=inflater.inflate(R.layout.fragment_clue_other,container,false);
        txt_addtional= (TextView) rootview.findViewById(R.id.fragment_clue_other_addtional);
        txt_clue_source= (TextView) rootview.findViewById(R.id.fragment_clue_other_clue);
        txt_create_time= (TextView) rootview.findViewById(R.id.fragment_clue_other_create_time);
        txt_creater= (TextView) rootview.findViewById(R.id.fram_clue_other_creater);
        txt_department= (TextView) rootview.findViewById(R.id.fram_clue_other_department);
        txt_next_content= (TextView) rootview.findViewById(R.id.fragment_clue_other_next_content);
        txt_update_time= (TextView) rootview.findViewById(R.id.fram_clue_other_update_time);
        txt_updater= (TextView) rootview.findViewById(R.id.fragment_clue_other_updater);
        txt_respectful= (TextView) rootview.findViewById(R.id.fragment_clue_other_respectful);
        txt_next_time= (TextView) rootview.findViewById(R.id.fragment_clue_other_next_time);
        clue= GetClue.get();
        txt_addtional.setText(clue.getClue_additional());
        txt_department.setText(clue.getClue_department());
        txt_next_content.setText(clue.getClue_next_content());
        if (String.valueOf(clue.getClue_current_create_id())!=null){
            txt_creater.setText(clue.getClue_current_create_id()+"");
        }
        txt_updater.setText(clue.getClue_current_update_id()+"");
        if (clue.getClue_create_time()!=null){
            SimpleDateFormat sdf = new SimpleDateFormat(" yyyy-MM-dd  ");
            sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
            String create_time=clue.getClue_create_time();
            long l=Long.parseLong(create_time);
            Date date = new Date(l);
            String cTime=sdf.format(date);
            txt_create_time.setText(cTime);
        }
        if (clue.getClue_update_time()!=null){
            SimpleDateFormat sdf = new SimpleDateFormat(" yyyy-MM-dd  ");
            sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
            String update_time=clue.getClue_update_time();
            long l=Long.parseLong(update_time);
            Date date = new Date(l);
            String uTime=sdf.format(date);
            txt_update_time.setText(uTime);
        }
        if (clue.getClue_next_time()!=null&&!clue.getClue_next_time().equals("")) {
            boolean b = clue.getClue_next_time().matches("\\d{4}-\\d{2}-\\d{2}");
            if (b) {
                txt_next_time.setText(clue.getClue_next_time());
            } else {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
                String next_time = clue.getClue_next_time();
                long l = Long.parseLong(next_time);
                Date date = new Date(l);
                String nTime = sdf.format(date);
                txt_next_time.setText(nTime);
            }
        }


        return rootview;
    }
}
